﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using Bootstrap5.Abstractions;

namespace Bootstrap5.Design
{
   abstract  class ClassDecoratorProvider: IClassDecoratorProvider
    {        
        bool _dirty = true;

        protected void SetDirty() => _dirty = true;
        protected void ClearDirty() => _dirty = false;

        protected List<string> Rules { get; set; } = new List<string>();

        protected abstract void BuildClass();

        public string BuildClass(ICssClassBuilder builder)
        {
            if (_dirty)
            {
                BuildClass();
                builder.Add(Rules);
                ClearDirty();
            }
            return builder.ToString();
        }
    }
}
